enum
{
COLUMN_NAME,
- COLUMN_PATH
+ COLUMN_PATH,
+ COLUMN_COUNT,
+ COLUMN_SIZE
};
struct _GtkInspectorResourceListPrivate
GtkTextBuffer *buffer;
GtkWidget *image;
GtkWidget *content;
+ GtkWidget *type;
GtkWidget *type_label;
+ GtkWidget *count;
+ GtkWidget *count_label;
GtkWidget *size_label;
GtkWidget *info_grid;
};
static void
load_resources_recurse (GtkInspectorResourceList *sl,
GtkTreeIter *parent,
- const gchar *path)
+ const gchar *path,
+ gint *count_out,
+ gsize *size_out)
{
gchar **names;
gint i;
gint len;
gchar *p;
gboolean has_slash;
+ gint count;
+ gsize size;
p = g_strconcat (path, names[i], NULL);
COLUMN_PATH, p,
-1);
+ count = 0;
+ size = 0;
+
if (has_slash)
- load_resources_recurse (sl, &iter, p);
+ {
+ load_resources_recurse (sl, &iter, p, &count, &size);
+ }
+ else
+ {
+ count = 1;
+ g_resources_get_info (p, 0, &size, NULL, NULL);
+ }
+
+ gtk_tree_store_set (sl->priv->model, &iter,
+ COLUMN_COUNT, count,
+ COLUMN_SIZE, size,
+ -1);
+ *count_out += count;
+ *size_out += size;
g_free (p);
}
GBytes *bytes;
gchar *type;
gconstpointer data;
+ gint count;
gsize size;
GError *error = NULL;
gtk_tree_model_get (GTK_TREE_MODEL (rl->priv->model), &iter,
COLUMN_PATH, &path,
COLUMN_NAME, &name,
+ COLUMN_COUNT, &count,
+ COLUMN_SIZE, &size,
-1);
if (g_str_has_suffix (path, "/"))
{
+ gchar *text;
+
+ text = g_strdup_printf ("%d", count);
+ gtk_label_set_text (GTK_LABEL (rl->priv->count_label), text);
+ g_free (text);
+
+ text = g_format_size (size);
+ gtk_label_set_text (GTK_LABEL (rl->priv->size_label), text);
+ g_free (text);
+
+ gtk_widget_hide (rl->priv->type);
+ gtk_widget_hide (rl->priv->type_label);
+ gtk_widget_show (rl->priv->count);
+ gtk_widget_show (rl->priv->count_label);
+ gtk_widget_show (rl->priv->info_grid);
+
gtk_text_buffer_set_text (rl->priv->buffer, "", -1);
gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "text");
goto out;
gtk_label_set_text (GTK_LABEL (rl->priv->size_label), text);
g_free (text);
+ gtk_widget_show (rl->priv->type);
+ gtk_widget_show (rl->priv->type_label);
+ gtk_widget_hide (rl->priv->count);
+ gtk_widget_hide (rl->priv->count_label);
gtk_widget_show (rl->priv->info_grid);
if (g_content_type_is_a (type, "text/*"))
static void
load_resources (GtkInspectorResourceList *sl)
{
+ gint count = 0;
+ gsize size = 0;
- load_resources_recurse (sl, NULL, "/");
+ load_resources_recurse (sl, NULL, "/", &count, &size);
}
static void
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, content);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, image);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, type_label);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, type);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, count_label);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, count);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, size_label);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorResourceList, info_grid);
<columns>
<column type="gchararray"/>
<column type="gchararray"/>
+ <column type="gint"/>
+ <column type="guint64"/>
</columns>
</object>
<object class="GtkTextBuffer" id="buffer">
<property name="column-spacing">10</property>
<property name="margin">20</property>
<child>
- <object class="GtkLabel">
+ <object class="GtkLabel" id="type">
<property name="visible">True</property>
<property name="label" translatable="yes">Type:</property>
<property name="halign">end</property>
<property name="top-attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="count">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Count:</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="count_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">1</property>
+ <property name="top-attach">2</property>
</packing>
</child>
<child>
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">1</property>
+ <property name="top-attach">2</property>
</packing>
</child>
</object>